//
//  HMFactory.swift
//  WeiBo
//
//  Created by apple on 16/7/5.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit


class HMFactory {
    
    /*
        工厂设计模式: 由父类定义协议,子类去实现
    */
    
    //  文字, 图片,tag,方法,target,font
    class func getButton(title: String,image: String,tag: Int,method: String,target: AnyObject,font: CGFloat) ->UIButton{
        
        
        let button = UIButton(type: UIButtonType.Custom)
        
        button.setTitle(title, forState: UIControlState.Normal)
        button.setImage(UIImage(named: image), forState: UIControlState.Normal)
        
        button.tag = tag
        // targe千万不要写self
        button.addTarget(target, action: Selector(method), forControlEvents: UIControlEvents.TouchUpInside)
        
        button.titleLabel?.font = UIFont.systemFontOfSize(font)
        
        return button
        
    }
    
}